<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html 
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"  
	xmlns:p="http://primefaces.org/ui"
>
	<h:head>
		<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
		<title>Produtos</title>
	</h:head>
	<h:body>
		<h:form>
			<p:commandButton value="Incluir produtos" action="/incluirProduto" />
		</h:form>
		
		<h:form id="formProdutos">
			
				<p:dataTable var="prod" value="#{produtoBean.produtos}" id="produtosList">
					
					
					<p:column>
						<f:facet name="header">Cod</f:facet>
						<h:outputText value="#{prod.codigo}" />
					</p:column>
					
					<p:column>
						<f:facet name="header">Nome</f:facet>
						<h:outputText value="#{prod.nome}" />
					</p:column>
					
					<p:column>
						<f:facet name="header">Descricao</f:facet>
						<h:outputText value="#{prod.descricao}" />
					</p:column>
					
					<p:column>
						<f:facet name="header">Alterar</f:facet>
						<h:graphicImage url="/img/edit_16x16.png"></h:graphicImage>
					</p:column>
					
					
					<p:column>
						<f:facet name="header">Excluir</f:facet>
						
						<p:commandLink oncomplete="dlgConfirmExc.show()">
							<f:setPropertyActionListener target="#{produtoBean.produtoSelec}" value="#{prod}"></f:setPropertyActionListener>
							<f:setPropertyActionListener target="#{produtoBean.deleta}" value=""></f:setPropertyActionListener>
							 
							<h:graphicImage url="/img/delete_16x16.png"></h:graphicImage>
						</p:commandLink>
					</p:column>
				</p:dataTable>
			
			
			<p:confirmDialog id="confirm" widgetVar="dlgConfirmExc" header="Excluir?" message="Tem certeza que deseja exlcuir?">
				<p:commandButton value="Sim" action="#{produtoBean.deleta}" update="produtosList" oncomplete="dlgConfirm.hide()" ></p:commandButton>
				<p:commandButton value="Cancelar" action="#{produtoBean.cancelaOp}" oncomplete="dlgConfirm.hide()"></p:commandButton>
			</p:confirmDialog>
		
		
		</h:form>
		
	</h:body>
</html>